package com.suxin.exception.assertM;

/**
 * @author Tang
 * @classname Assert
 * @description [  ]
 * @date 2022/10/27 14:47
 */
public interface Assert {

    /**
     * 创建异常
     * @param args
     * @return
     */
    BaseException newException(Object target,Object ...args);

    /**
     * 创建异常
     * @param throwable
     * @param args
     * @return
     */
    BaseException newException(Throwable throwable,Object target,Object ...args);

    /**
     * assertNotNull
     * @param target
     */
    default void assertNotNull(Object target) {
        if (target == null) {
            throw newException(target);
        }
    }

    /**
     * assertNotNull
     * @param target
     * @param args
     */
    default void assertNotNull(Object target,Object ...args) {
        if (target == null) {
            throw newException(target,args);
        }
    }

}
